<html>
    <head>
        <title>判断操作系统</title>
        <script type="text/javascript">
            function detectOS() { 
                var sUserAgent = navigator.userAgent; 
                console.log(sUserAgent)
                var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows"); 
                var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel"); 
                if (isMac) return "Mac"; 
                var isUnix = (navigator.platform == "X11") && !isWin && !isMac; 
                if (isUnix) return "Unix"; 
                var isLinux = (String(navigator.platform).indexOf("Linux") > -1); 
                
                var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) == "android";
                if (isLinux) {
                    if(bIsAndroid) return "Android";
                    else return "Linux"; 
                }
                if (isWin) { 
                    var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1; 
                    if (isWin2K) return "Win2000"; 
                    var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || 
                    sUserAgent.indexOf("Windows XP") > -1; 
                    if (isWinXP) return "WinXP"; 
                    var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1; 
                    if (isWin2003) return "Win2003"; 
                    var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1; 
                    if (isWinVista) return "WinVista"; 
                    var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1; 
                    if (isWin7) return "Win7"; 
                } 
                return "other"; 
            } 
            document.writeln("您的操作系统是：" + detectOS()); 
        </script>
        <script>
            // 判断是移动端还是PC端
            function isPC() {
                var userAgentInfo = navigator.userAgent
                console.log(userAgentInfo)
                var Agent = ['Android','iPhoone','SymbianOS','Windows Phone','iPad','iPod']
                var flag = true
                for(var v = 0; v <  Agent.length; v++) {
                    if(userAgentInfo.indexOf(Agent[v]) > 0) {
                        flag = false
                        break
                    }
                }
                return flag
            }
            // 判断是哪个手机端系统平台
            function whichPhone() {
                var userAgentInfo = navigator.userAgent
                if(userAgentInfo.indexOf('Android') > -1 || userAgentInfo.indexOf('Linux') > -1) {
                    alert('Android')
                } else if(userAgentInfo.indexOf('iPhone') > -1) {
                    alert('iPhone')
                } else if(userAgentInfo.indexOf('Window Phone') > -1) {
                    alert('winphone手机')
                }
            }
            // 判断是够在微信打开
            function isWeChat() {
                var userAgentInfo = navigator.userAgent
                if(userAgentInfo.indexOf('micromessenger') != -1) {
                    return true
                } else {
                    return false
                }
            }
        </script>
    </head>
    <body>
    </body>
</html>